package com.zhaokuner.echo;

import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;

public class HanldleMsg implements Runnable {
	SelectionKey sk;
	ByteBuffer bb;

	public HanldleMsg(SelectionKey sk, ByteBuffer bb) {
		this.sk = sk;
		this.bb = bb;
	}

	@Override
	public void run() {
		EchoClientModel echoClient = (EchoClientModel) sk.attachment();
		echoClient.enqueue(bb);
		sk.interestOps(SelectionKey.OP_READ | SelectionKey.OP_WRITE);
		// 强迫 selector立即返回
		echoClient.getSelector().wakeup();
	}

}
